package com.study.manage.mvc.org.judges;

import java.util.HashMap;
import java.util.Map;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.study.manage.dal.EvaluateJuryRepository;

@Service
public class JudgesService {

	@Autowired
	private EvaluateJuryRepository repository;

	public Map<String, Object> getBaseData(Long id) {
    	
		Map<String, Object> map = new HashMap<>();
		map.put("count",repository.getJudgesNumber(id));
	    map.put("CommentNumber", repository.getCommentNumber(id,null));
	    map.put("ScoreNumber", repository.getScoreNumber(id,null));
	    map.put("id", id);
		return map;
	}

	public Object getScoreNumber(Long evaluateId, Long userId) {
		return repository.getScoreNumber(evaluateId,userId);
	}

	public Object getCommentNumber(Long evaluateId, Long userId) {
		return repository.getCommentNumber(evaluateId,userId);
	}

	public Object getPostNumber(Long evaluateId, Long userId) {
		return repository.getPostNumber(evaluateId,userId);
	}
	
	@Transactional
	public void deleteJudges(Long id) {
		repository.deleteJudges(id);
	}

    
}
